package com.xinlianshiye.im.service

import com.xinlianshiye.im.bean.App
import com.xinlianshiye.im.bean.User
import com.xinlianshiye.im.response.Page
import com.xinlianshiye.im.response.TemporaryUserinfo
import com.xinlianshiye.im.response.UserRecordlist
import javax.websocket.Session

interface UserService {
    /**
     * 向用户发送初始化信息
     */
    fun sendInit(userId: Int?)

    /**
     * 注册用户(不要没有看到有地方引用就删， 是给其它项目调用的)
     */
    fun create(username: String?, sign: String?, avatar: String?, appId: String?): User
    fun getOrElseThrow(userId: Int?): User

    // 修改个性签名信息
    fun updSign(userId: Int?, sign: String?): User
    fun updName(userId: Int?, name: String?): User
    fun updAvatar(userId: Int?, avatar: String?): User

    /**
     * @Author zw
     * @Description 根据用户id 查询聊天记录 根据是否读取过 排序 未读取优先级高  好友分组 取最新一条数据  有几条未查阅的信息
     * @Date 21:00 2019/8/14
     * @Param
     */
    fun findUseridRecordCustom(userId: Int?, search: String?): Page<UserRecordlist>

    /**
     * 临时获取聊天对象的信息和聊天记录（尚未通过好友申请）
     */
    @Throws(Exception::class)
    fun getTemporaryContactAndRecord(userId: Int?, other: Int?): TemporaryUserinfo
    fun findById(id: Int?): User
    fun getUserId(session: Session): Int?
    fun setUserId(session: Session, userId: Int?)
    fun genAccessToken(user: User): String
    fun verifyAccessToken(accessToken: String, app: App): User
}